package cj.primariaiquest.ws.xmlConfig;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.integration.annotation.MessageEndpoint;

@MessageEndpoint
public class MainScreen {
	private static List<Map<String, Long>> officeAndTicketNo;
	
	static{
		officeAndTicketNo = new ArrayList<Map<String,Long>>();
		officeAndTicketNo.add(new ConcurrentHashMap<String, Long>());
		officeAndTicketNo.add(new ConcurrentHashMap<String, Long>());
		officeAndTicketNo.add(new ConcurrentHashMap<String, Long>());
	}

	public void mainScreenEndpoint(Ticket ticket) {
		addTicket(ticket);
		   for (int i=0; i < officeAndTicketNo.size(); i++){
			   System.out.println(officeAndTicketNo.get(i));
		   }
//		System.out.println(ticket.getDepartment()+ " " + ticket.getOffice()+ " " +ticket.getNumber() );
		System.out.println("-------------------");

	}
	
	public void addTicket(Ticket ticket){
		if (ticket.getDepartment().equals(DepartmentType.HumanResources)){
			officeAndTicketNo.get(0).put(ticket.getOffice(), ticket.getNumber());
		}
		else
			if (ticket.getDepartment().equals(DepartmentType.Administrative)){
				officeAndTicketNo.get(1).put(ticket.getOffice(),ticket.getNumber() + 1);
				}
			else
			  if (ticket.getDepartment().equals(DepartmentType.LocalTaxes)){
				officeAndTicketNo.get(2).put(ticket.getOffice() , ticket.getNumber() + 1);
			}
	}
}
